package com.kaguya.vams.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaguya.vams.service.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

import com.kaguya.vams.domain.Result;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.ServletRequestUtils;

/**
 * 基础控制层
 * @author : kaguya
 * @date : 16:54 2021/7/28
 */
public class BaseController {

    @Autowired
    HttpServletRequest req; //请求

    @Autowired
    SysUserService userService; //用户服务层

    @Autowired
    SysMenuService menuService; //菜单服务层

    @Autowired
    SysRoleService roleService; //角色服务层

    @Autowired
    SysUserRoleService userRoleService; //用户角色关联服务层

    @Autowired
    SysRoleMenuService roleMenuService; //角色菜单关联服务层

    @Autowired
    SysDictService dictService; //数字字典服务层

    @Autowired
    BCryptPasswordEncoder encoder; //密码加密


    /**
     * 从请求中获取分页参数 默认值1页开始 每页10条
     * @return Page
     */
    public Page getPage(){
        // HttpServletRequest请求对象 参数名 默认值
        int page = ServletRequestUtils.getIntParameter(req, "page", 1);
        int limit = ServletRequestUtils.getIntParameter(req, "limit", 10);
        return new Page(page,limit);
    }
}
